package org.liveboardgames.agricola.view.component
{
	import mx.controls.Image;
	
	import org.liveboardgames.agricola.model.enums.AbstractEnum;

	public class FenceImage extends Image
	{
		private var _color:String;

		public function FenceImage()
		{
			super();
		}

		public function set color(color:String):void
		{
			this._color = color;
			updateSource();
		}

		public function get color():String
		{
			return this._color;
		}

		private function updateSource():void
		{
			if (this.width > this.height)
			{
				//this.source = "../assets/images/common/farm/" + color.name + "Fence.png";
				this.source = ImageHandler.FARM_ELEMENTS_ROOT_PATH + AbstractEnum.toTitleCase(color) + "Fence.png";
			}
			else
			{
				//this.source = "../assets/images/common/farm/" + color.name + "FenceVertical.png";
				this.source = ImageHandler.FARM_ELEMENTS_ROOT_PATH + AbstractEnum.toTitleCase(color) + "FenceVertical.png";
			}
			this.setStyle("backgroundSize", "100%");
		}
	}
}